<%@ page language="java" pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
	function delConfirm(){
		var result = window.confirm('确认要删除该项吗？')
		return result;
	}
	
	function findIdcard(){
	    var userNameElements = document.getElementsByName("user_name");
        var uesrname = userNameElements[0].value;
        var idcardNoElements = document.getElementsByName("idcard_no");
        var idcardNo = idcardNoElements[0].value;
        console.log("搜索的用户名为："+uesrname);
        console.log("搜索的身份证号为："+idcardNo);
	    location.href="${pageContext.request.contextPath }/servlet/showidcardservlet?username="+uesrname+"&idcardNo="+idcardNo;
		
    }
            
</script>
</head>
<body>

	<table border='1px' align='center' width='70%' cellpadding='0'
		cellspacing='0'>
		<tr align="center">
			<td colspan='4' align='left'>
				按用户名查找：<input type="text" name="user_name"><button onclick="findIdcard()">搜索</button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				按身份证号查找：<input type="text" name="idcard_no"><button onclick="findIdcard()">搜索</button>&nbsp;&nbsp;&nbsp;
                <button onclick="findIdcard()">全部</button>
			</td>
		</tr>
		<tr align='center'>
			<td>编号</td>
			<td>身份证号</td>
			<td>用户名</td>
			<td>操作</td>
		</tr>
<!-- session.setAttribute("idcardPage", pageUnitForIdcard); -->
		<c:forEach var="idcard" items="${idcardPage.idcardList }" varStatus="idcardstatus">
			<tr align='center'>
				<td>${idcardstatus.count }</td>
				<td>${idcard.idcardNo }</td>
				<td>${idcard.user.userName }</td>
				<td>
				  <%--<a href='${pageContext.request.contextPath }/servlet/updateuserpageservlet?id=${user.userId}'>更新</a>&nbsp;&nbsp;&nbsp;&nbsp;--%>
				  <a href='${pageContext.request.contextPath }/servlet/delectidcardservlet?id=${idcard.idcardId}' onclick="return delConfirm()">删除</a>
				</td>
			</tr>
		</c:forEach>

		<tr>
			<td colspan='4' align='right'>共${idcardPage.pageNum }页&nbsp&nbsp&nbsp&nbsp <a
				href='${pageContext.request.contextPath }/servlet/showidcardservlet?currentPage=1'>首页</a>&nbsp;&nbsp;&nbsp;&nbsp;
				<a href='${pageContext.request.contextPath }/servlet/showidcardservlet?currentPage=${idcardPage.prePage}'>上一页</a>&nbsp;&nbsp;&nbsp;&nbsp;
				
				<c:forEach begin="1" end="${idcardPage.pageNum }" var="page" >
					<a href='${pageContext.request.contextPath }/servlet/showidcardservlet?currentPage=${page}'>${page}</a>&nbsp;&nbsp;&nbsp;&nbsp;
				</c:forEach>
				<a href='${pageContext.request.contextPath }/servlet/showidcardservlet?currentPage=${idcardPage.nextPage}'>下一页</a>&nbsp;&nbsp;&nbsp;&nbsp;
				<a href='${pageContext.request.contextPath }/servlet/showidcardservlet?currentPage=${idcardPage.pageNum }'>尾页</a>&nbsp;&nbsp;&nbsp;&nbsp;
			</td>
		</tr>
	</table>
</body>
</html>